-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ExcludeKey option to TextFormatter #1433
base: master
Are you sure you want to change the base?
Conversation
cd432c8
to
aedfb7c
Compare
@@ -331,9 +337,14 @@ func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { | |||
stringVal = fmt.Sprint(value) | |||
} | |||
|
|||
if !f.needsQuoting(stringVal) { | |||
// write value without quoting directly when ExcludeKey is true | |||
if f.ExcludeKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If configure ExcludeKey as true, just write value without quoting directly, otherwise, the logs will be as below
"0001-01-01T00:00:00Z" warning "message"
aedfb7c
to
a886e5b
Compare
b.WriteString(stringVal) | ||
} else { | ||
b.WriteString(fmt.Sprintf("%q", stringVal)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the same logic as before when ExcludeKey is false(this is default)
Can someone review this PR? |
AS-IS (
ExcludeKey : false
, this is default)TO-BE (after applied
ExcludeKey : true
)I think this is a common case, when
some log collector agent
collect the logs from file or standard output, does not need the startingKey(e.g.time=
)